package com.zengqingfa.springboot.validation.demo.annotation;

import com.zengqingfa.springboot.validation.demo.validator.ListValueConstraintValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 自定义校验注解
 */
@Documented
//使用的位置
@Constraint(validatedBy = ListValueConstraintValidator.class)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)//运行时机
public @interface ListValue {
    //========JSR规范指定必须有这3个===============
    String message() default "{com.zengqingfa.springboot.validation.demo.annotation.ListValue.message}";//在配置文件中定义

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
    //=======================

    //自己写规则
    int[] vals() default {};
}

